package com.app.dmm.modules.banner.controller;

import com.app.dmm.core.ApiResult;
import com.app.dmm.core.controller.BaseController;
import com.app.dmm.modules.banner.entity.SysBanner;
import com.app.dmm.modules.banner.service.SysBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/sys/banner")
public class SysBannerController extends BaseController {

    @Autowired
    private SysBannerService sysBannerService;

    @PostMapping("/list")
    public ApiResult<List<SysBanner>> findAll(SysBanner banner) {
        List<SysBanner> bannerList = sysBannerService.findAll();
        return super.message(0, "查询成功", bannerList);
    }

    @PostMapping("/save")
    public ApiResult<String> save(SysBanner banner) {
        int a = sysBannerService.save(banner);
        if (a == 1) {
            return super.success("保存成功");
        }
        return super.message(1, "保存失败", null);
    }

}
